package com.ww.scm.entity.pub;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "T_PUB_SEQUENCE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
// 序列表
public class Sequence {

	private String id;
	private String key;
	private Integer value;

	public Sequence() {
	}
	
	public Sequence(String key) {
		this.key=key;
		this.value=1;
	}

	@Id
	@Column(name = "F_ID", nullable = false, length = 32)
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	public String getId() {
		return id;
	}

	@Column(name = "F_KEY", nullable = false, length = 128)
	public String getKey() {
		return key;
	}

	@Column(name = "F_VALUE", nullable = false, precision = 8, scale = 0)
	public Integer getValue() {
		return value;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public void setValue(Integer value) {
		this.value = value;
	}
	
	public void addValue(Integer poolSize) {
		this.value = value+poolSize;
	}
}
